package com.wzdigit.wms.basic.enums;

import java.util.*;

/**
 * @ClassName OqcInspStatusEnum
 * @Description OQC送检单状态
 * @Author LHR-PC
 * @Date 2021/1/25 10:33
 * @Version
 **/
public enum OqcInspStatusEnum implements BaseEnum{
    OQC_STATUS_UN_HANDLE(0,"未处理","未处理"),
    OQC_STATUS_PART_HANDLE(1,"部分处理","部分处理"),
    OQC_STATUS_AFTER_HANDLE(2,"已处理","已处理");

    /**
     * 枚举值
     */
    public int code;

    /**
     * 枚举名称
     */
    public String enumName;

    /**
     * 枚举实体类属性描述
     *
     * @return
     */
    public String description;


    OqcInspStatusEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    OqcInspStatusEnum(int code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static OqcInspStatusEnum getEnumByCode(int enumCode) {
        OqcInspStatusEnum[] values = OqcInspStatusEnum.values();
        OqcInspStatusEnum samplingEnum = null;

        for (OqcInspStatusEnum value : values) {
            if (value.getCode() == enumCode) {
                samplingEnum = value;
            }
        }
        return samplingEnum;
    }

    public static OqcInspStatusEnum getEnumByName(String enumName) {
        OqcInspStatusEnum[] values = OqcInspStatusEnum.values();
        OqcInspStatusEnum repairEnum = null;

        for (OqcInspStatusEnum value : values) {
            if (value.getEnumName() == enumName) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public static Map<Integer, String> getEnumByDescription(String enumDescription) {
        Map<Integer, String> enumMap = new HashMap<>();

        OqcInspStatusEnum[] values = OqcInspStatusEnum.values();
        for (OqcInspStatusEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static Integer getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        OqcInspStatusEnum[] values = OqcInspStatusEnum.values();
        for (OqcInspStatusEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }


    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        OqcInspStatusEnum[] values = OqcInspStatusEnum.values();
        for (OqcInspStatusEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
}
